<template>
	<view class="detail-ap">
		<view class="tabList">
			<v-tabs v-model="tabCurrent" :scroll="false" :tabs="tabList1" @change="tabChange" ></v-tabs>
		</view>
		<view class="main-container">
			<swiper :current="tabCurrent" @change="changesw" duration="300">
				<swiper-item v-for="(item, tabIdx) in tabList" class="main-panel-wrap" :key='tabIdx'>
					<view class="mian-title">
						<view class="xq_title" @click="updatechepaimsg" >场地出土申报 </view>
						<view class="xq_type" v-if="detailList.isClosed == 0">
							当前节点：{{ nodeName }}
						</view>
						<view class="" style="padding: 36rpx;" v-if="detailList.isClosed == 0">
							<steps :steps='stepArr' :current="stepsnumber"></steps>
						</view>
					</view>
					<!-- 审核历史组件 -->
					<circullog class="mian-content" v-if="tabIdx == 1"></circullog>
					<!-- 审核详情 -->
					<view v-else class="scroll-class mian-content">
						<view class="forms-container">
							<sk-field label=" " value="pdf已生成" isLink valueColor="#428ffc" v-if="!finnished"></sk-field>
							<sk-field label="出土场地" :value="detailmsg.siteName"></sk-field>
							<sk-field label="详细地址" :value="detailmsg.siteAddress"></sk-field>
							<!-- <sk-field label="建筑垃圾类别" :value="detailmsg.garbageType"></sk-field> -->
							<sk-field label="运输开始时间" :value="detailmsg.transitStartTime"></sk-field>
							<view class="items" v-if="(stepsnumber==3 && orderType == 1)  || stepsnumber == 4">
								<view class="field" :class="[stepsnumber==3?'edit-field':'']">
									运输结束时间
								</view>
								<view class="content edit-field" @click="showcalendar = true"
									v-if="stepsnumber==3 && orderType == 1">
									{{time || '请选择' }}
								</view>
								<view class="content" v-else>
									{{time || '暂无' }}
								</view>
							</view>
							<view class="items" v-if="stepsnumber == 4 && orderType == 1">
								<view class="field edit-field">
									禁行时间
								</view>
								<view class="content" style="color: #363A44;">
									<u-input v-model="banTime" :type="text" placeholder="请输入" />
								</view>
							</view>
							
							<sk-field label="渣土" :value="detailmsg.muckEarthQuantity" :otherText="0"></sk-field>
							<sk-field label="黄土" :value="detailmsg.loessEarthQuantity" :otherText="0"></sk-field>
							<sk-field label="种植土" :value="detailmsg.plantingSoilEarthQuantity" :otherText="0">
							</sk-field>
							<sk-field label="泥浆" :value="detailmsg.slurryEarthQuantity" :otherText="0"></sk-field>
							<sk-field label="建筑废砖" :value="detailmsg.wasterEarthQuantity" :otherText="0"></sk-field>
							<sk-field label="宕渣" :value="detailmsg.dangEarthQuantity" :otherText="0"></sk-field>
							<sk-field label="其他" :value="detailmsg.otherEarthQuantity" :otherText="0"></sk-field>
							<sk-field label="总量" :lableColor="lableColor" :value="detailmsg.allEarthQuantity"
								:otherText="0">
							</sk-field>
							<sk-field label="运输
							结束时间" :value="detailmsg.transitEndTime"></sk-field>
							<sk-field label="运输方式"
								:value="detailmsg.transitModeCar==1 ? '工程车' :detailmsg.transitModeCar== 0 ? '船' : ''">
							</sk-field>
							<sk-field label="消纳点" :value="detailmsg.absorbName"></sk-field>
							<sk-field label="导航路线" :value="routeValue" isLink valueColor="#428ffc" @click="createRoute">
							</sk-field>
							<sk-field  label="通行证" v-if="stepsnumber==4 && orderType == 1"
								:value="pdfValue" :isLink="detailList.isClosed == 0"
								:valueColor="detailList.isClosed == 0 ? '#428ffc' : ''" @click="createTongxingzhengPdf">
							</sk-field>
							<!-- <view v-for="item2 in transitCompanyInfo"><span>{{item2.companyName}}</span><span>12222222222</span></view> -->
							<view v-if="stepsnumber >= 1" class="item-penel">
								<view class="items items2" :style="baseDataBoxStyle">
									<view class="car-wraper" v-if="(stepsnumber == 4 && orderType == 1) || (stepsnumber == 3 && orderType == 1) || stepsnumber == 1 " >
										<view class=""  v-for="(item2,index2) in  detailmsg.transitCompanyInfo" >
											<view class="title-wraper">
												<view class="title">运输企业</view>
												<view class="name">{{item2.companyName}}</view>
											</view>
											<div class="title-wraper">
												<div class="title">联系人</div>
												<div class="name">{{item2.contacts}}</div>
											</div>
											<div class="title-wraper">
												<div class="title">联系人电话</div>
												<div class="name">{{item2.contactNum || '暂无'}}</div>
											</div>
											<view class="content-item-wrapper" v-show="item2.carList.length" >
												<view class="title"><span>共{{item2.carList.length}}辆</span><span></span>
												</view>
												<view class="name">
													<u-checkbox-group @change="checkboxGroupChange()">
														<u-checkbox v-model="item.checked"
															@change="checkboxGroupChange(index2)"
															v-for="(item, index) in item2.carList" :key="index"
															:name="item.plateNumber">
															({{index+1}}){{item.plateNumber}}
														</u-checkbox>
													</u-checkbox-group>
												</view>
											</view>
										</view>
										
									</view>
									<!-- 交警外 -->
									<div class="car-wraper" v-else >
										<view v-for="(item2,index2) in  detailmsg.transitCompanyInfo"  >
											<div class="title-wraper">
												<div class="title">运输企业</div>
												<div class="name">{{item2.companyName}}</div>
											</div>
											<div class="title-wraper">
												<div class="title">联系人</div>
												<div class="name">{{item2.contacts}}</div>
											</div>
											<div class="title-wraper">
												<div class="title">联系人电话</div>
												<div class="name">{{item2.contactNum || '暂无'}}</div>
											</div>
											<div class="content-wraper" v-for="(item3,index3) in item2.carList">
												<div class="content-item-wrapper">
													<div class="title"><span v-if="index3 == 0">企业车辆</span><span></span>
													</div>
													<div class="name">
														{{item2.carList.length !=0 ?  item3.plateNumber : '暂无车辆' }}
													</div>
												</div>
											</div>
										</view>
										
										<!-- 
										<div class="title-wraper">
											<div class="title">运输企业</div>
											<div class="name">{{item2.companyName}}</div>
										</div>
										<div class="content-wraper" v-for="(item3,index3) in item2.carList">
											<div class="content-item-wrapper">
												<div class="title"><span v-if="index3 == 0">企业车辆</span><span></span>
												</div>
												<div class="name">
													{{item2.carList.length !=0 ?  item3.plateNumber : '暂无车辆' }}
												</div>
											</div>
										</div> -->
									
									</div>
									
								</view>
								<!-- <view class="load-more" @click="loadMore()" v-if="!showMoreBaseData">
									<span v-if="detailmsg.transitCompanyInfo">查看更多 ></span>
								</view>
								<view class="load-more" v-else>
									<span>已加载所有</span>
								</view> -->
							</view>
							<view class="items"   v-if="stepsnumber == 4 && orderType == 1">
								<view class="field edit-field">
									备注
								</view>
								<view class="content" style="color: #363A44;">
									<u-input v-model="remarksMes" maxlength="50" type="textarea" :height="defaultHeight" :auto-height="autoHeight" placeholder="备注" />
								</view>
							</view>
						</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 审核通过弹窗 -->
		<u-popup v-model="showPass" mode="bottom " :border-radius="border_radius" mask>
			<view class="pop">
				<view class="title">
					<view class="" @click="showPass=false">
						取消
					</view>
					<view class="">
						通过
					</view>
					<view class="" style="color: #007AFF;" @click="onSure()">
						确认
					</view>
				</view>
				<view class="" style="margin:50rpx 20rpx 50rpx 20rpx ">
					<u-input :enableNative="false" style="" v-model="pass_value" :type="type" :border="border"
						:maxlength="500" :height="height" placeholder="请输入通过意见" />
				</view>
			</view>
		</u-popup>
		<u-popup v-model="show" mode="bottom " :border-radius="border_radius" mask>
			<view class="pop">
				<view class="title">
					<view class="" @click="show=false">
						取消
					</view>
					<view class="">
						{{outorder==1 ? '不通过' :outorder== 2? '退单整改': '审核' }}
					</view>
					<view class="" style="color: #007AFF;" @click="comfirm">
						确认
					</view>
				</view>
				<view class="" style="margin:50rpx 20rpx 50rpx 20rpx ">
					<!-- <u-input :enableNative="false" style="" v-model="type_value" :type="type" :border="border"
						:height="height" placeholder="请填写审核意见" /> -->
					<u-input v-if="outorder== 2" :enableNative="false" style="" v-model="type_value" :type="type"
						:maxlength="500" :border="border" :height="height" placeholder="请输入退单整改意见" />
					<u-input v-else-if="outorder== 1" :enableNative="false" style="" v-model="type_value" :type="type"
						:maxlength="500" :border="border" :height="height" placeholder="请输入不通过意见" />
					<u-input v-else :enableNative="false" style="" v-model="type_value" :type="type" :border="border"
						:maxlength="500" :height="height" placeholder="请输入审核意见" />
				</view>
			</view>
		</u-popup>
		<u-popup v-model="showpart" mode="bottom " :border-radius="border_radius" mask>
			<view class="pop">
				<view class="title">
					<view class="" @click="showpart = false"> 取消 </view>
					<view class="">
						{{ buttontype == 10 ? "请选择参与部门" : "分派处置" }}
					</view>
					<view class="" style="color: #007aff" @click="comfirm_part">
						确认
					</view>
				</view>
				<view class="checkbox-group" v-if="buttontype == 10">
					<u-checkbox-group>
						<u-checkbox @change="checkboxChange" v-model="item.checked" v-for="(item, index) in list"
							shape="circle" size="45rpx" :key="index" :name="item.orgId">{{ item.orgName }}</u-checkbox>
					</u-checkbox-group>
				</view>
				<view class="" style="margin: 50rpx 20rpx 50rpx 20rpx" v-else>
					<u-input :enableNative="false" v-model="type_value" :type="type" :border="border" :height="height"
						placeholder="请填写审核意见" />
				</view>
			</view>
		</u-popup>
		<view class="footer" v-if="circul==0 && finnished">
			<view class="">
				<button class="take-task" v-if="orderType==0" type="default" @click="takeClaim">
					任务认领
				</button>
				<!-- <button class="take-task" v-else-if="buttontype == 2" type="default" @click="showpart=true">部门选择</button>
				<button class="take-task" v-else-if="orderType == 3" type="default" @click="show=true">分派处置</button> -->
				<view class="footer" v-else>
					<!-- 1.是否通过 -->
					<view class="footer" v-if="buttontype == 1">
						<button class="chuzhi" type="default" @click="canceltake">取消认领</button>
						<button class="chuzhi" type="default" @click="forward()">转发</button>
						<button class="chuzhi" type="default" @click="passout(1)">不通过</button>
						<button class="chuzhi" type="default" @click="passout(2)">退单整改</button>
						<!-- <button class="chuzhi" type="default" @click="passin">通过</button> -->
						<button class="chuzhi" type="default" @click="approved()">通过</button>
					</view>
					<view class="footer" v-else-if="buttontype == 3">
						<button class="chuzhi" type="default" @click="canceltake">取消认领</button>
						<button class="chuzhi" type="default" @click="forward()">转发</button>
						<button class="chuzhi" type="default" @click="passout(1)">不通过</button>
						<button class="chuzhi" type="default" @click="passout(2)">退单整改</button>
						<!-- <button class="chuzhi" type="default" @click="comfirm_part">通过</button> -->
						<button class="chuzhi" type="default" @click="approved()">通过</button>
					</view>
					<view class="footer" v-else-if="buttontype == 6">
						<button class="take-task" type="default" @click="passout(1)">
							不通过
						</button>
					</view>
					<view class="footer" v-else>
						<button class="cancel" type="default" @click="passout(1)">不通过</button>
						<!-- <button class="confim" type="default" @click="comfirm_part">
							通过
						</button> -->
						<button class="confim" type="default" @click="approved()">
							通过
						</button>
					</view>
				</view>
			</view>
		</view>
		<view class="">
			<u-calendar v-model="showcalendar" :mode="mode" @change='setTime' max-date="2099-01-01" :min-date="minDate">
			</u-calendar>
		</view>
		<appoint-task :recordId="id" :personShow="personShow" @appointTaskSuccess="appointTaskSuccess"
			@appointTaskCancel="appointTaskCancel"></appoint-task>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		getOrderDetail,
		getTakeTask,
		postOrderHandle,
		orgByNodeId,
		allocate,
		allocatedo,
		postWithdraw,
		postOrderAudit,
		postCloseOrder,
		postCheck,
		postBackStep,
		cancelTask,
		getWorkOrderLogs,
		getMyList,
		allocatepostWithdraw
	} from "@/pages/api/orderp/orderp.js";
	import {
		postUpdateTask,
		getByOrdersId,
		getLicenseXukeZhengData,
	} from "@/api/indexApprove.js"
	import {
		updatechandi,
		updateCheckCarInfo
	} from '@/pages/api/report/orderp.js'
	import circullog from '@/pages/index/approval/circulLog/index'
	import steps from '@/components/orderStep/orderStep.vue';
	import appointTask from '@/components/appointTask/index.vue'
	import {
		mapState,
		mapMutations
	} from 'vuex';
	let ins = 0
	export default {
		components: {
			circullog,
			steps,
			appointTask
		},
		onLoad(op) {
			this.id = op.id;
			this.nodeId = op.nodeId;
			this.flag = op.flag;
			this.orderId = op.idd;
			this.setOrderIdSp(op.idd)
			this.nodeName = op.nodeName
			this.circul = op.currenttab
			this.checkop = op.checkop[0]
			this.stepsnumber = op.stepsnumber
			console.log('*****************场地出土参数: ', this.stepsnumber)
			this.getdetail()
			this.getorgByNodeId()
			this.getolddetail()
			this.requestGetLicense()
			this.getcircul()

		},
		created() {
			uni.$on('busSetRoutePath', data => {
				console.log('接收到导航: ', data)
				// this.$set(this.detailmsg, 'transitRoute', data.routePath)
				this.detailmsg.transitRoute =data.routePath
				this.detailmsg.transitRouteText =data.routeText
				// this.$set(this.detailmsg, 'transitRouteText', data.routeText)
				this.routeText = data.routeText
				let p = {
					ordersId: this.orderId,
					transitRoute: data.routePath || '',
					transitRouteText: data.routeText || '',
				}
				console.log(p)
				// 审核通过后上传路线
				 postUpdateTask(p).then(res => {
					 this.$toast('路线上传成功')
					 this.isUploadRoute = true
					// if(this.stepsnumber == 4 ) {
					// 	this.updatechepaimsg() //更新车牌
					// }
					
				}).catch(err => {
					this.isUploadRoute = false
					console.log('路线上传失败: ', err)
					this.$toast('路线上传失败,请重新选择路线')
					return Promise.reject()
				})
			})
			uni.$on('busSetRouteTxzPdf', param => {
				console.log('接收到pdf: ', param)
				// this.$set(this.detailmsg, 'transportTaskApplication', param.url)
				// 如果是从通过进入则直接通过操作
				// if (param.isOpreate) {
				//  10-18
				// this.confirmPassed()
				this.detailmsg.transportTaskApplication = true
				// this.pdfValue = '通行证已生成'
				console.log(9999,this.detailmsg.transportTaskApplication)
				this.getdetail()
				// }
			})
			uni.$on('SetFinnishPdf', param => {
				console.log('接收到pdf: ', param, this.detailmsg.ordersId)
				// this.$set(this.detailmsg, 'transportTaskDisposalForm', param)
				this.$nextTick(() => {
					this.finnished = false
					
					this.$toast('pdf已生成')
				})

			})
		},
		destroyed() {
			console.log('*****场地出土销毁了')
			uni.$off('busSetRoutePath');
			uni.$off('busSetRouteTxzPdf');
			uni.$off('SetFinnishPdf');
		},
		computed: {
			...mapState('mdOrder', []),
			routeValue() {
				if (this.stepsnumber == 4) {
					return this.routeText || '查看路线'
				} else {
					return '查看路线'
				}
			},
			pdfValue() {
				if (this.detailmsg.transportTaskApplication) {
					return '通行证已生成'
				} else {
					return '点击生成通行证'
				}
			}
		},
		data() {
			return {
				autoHeight: true,
				defaultHeight: 50,
				remarksMes: '',//备注信息
				personShow: false, //转发人员弹窗
				lableColor: '#2F6AFF',
				id: "",
				detailList: {},
				timeLeft: "",
				formarr: [],
				show: false,
				showcalendar: false,
				showPass: false,
				showpart: false,
				type: "textarea",
				border: true,
				height: 240,
				type_value: "",
				pass_value: '',
				border_radius: "30rpx",
				orderType: "",
				nodeId: "",
				list: [],
				activelist: [],
				flag: false,
				orderId: "",
				buttontype: 0,
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
				value: "orange",
				outorder: 0,
				polyline: [],
				detailmsg: {},
				nodeName: '',
				points: [],
				checkop: 0,
				mode: 'date',
				tabList: [{
						name: '审核详情'
					},
					{
						name: '审核历史'
					}
				],
				tabList1: [ '审核详情', '审核历史'],
				tabCurrent: 0,
				circul: 0,
				stepArr: [{
					name: '提交申请'
				}, {
					// name: '交水审核'
					name: '消纳审核'
				}, {
					name: '运输企业'
				}, {
					name: '渣土办'
				}, {
					name: '交警审核'
				}],
				stepsnumber: 0,
				baseDataBoxStyle: {
					// height: "90rpx",
					overflow: "hidden"
				},
				showMoreBaseData: false,
				time: '', //运输结束时间
				banTime: '22:00-07:00', //禁行时间
				// 通行证数据
				licenseData: [],
				minDate: '1950-01-01',
				circulList: [],
				finnished: true,
				transitCompanyInfo: [], //运输企业信息
				carslist: [{
						name: 'apple',
						checked: false,
						disabled: false
					},
					{
						name: 'banner',
						checked: false,
						disabled: false
					},
					{
						name: 'orange',
						checked: false,
						disabled: false
					},
					{
						name: 'jk',
						checked: false,
						disabled: false
					},
					{
						name: 'jkjkjkjk',
						checked: false,
						disabled: false
					},
					{
						name: '7t7tikk',
						checked: false,
						disabled: false
					}
				],
				plateNumberList:[[],[],[],[],[],[],[],[],[],[],[],[],[],[]],//车牌
				routeText:'',
				isUploadRoute:true
			};
		},
		methods: {
			...mapMutations('mdOrder', ['setOrderIdSp', 'setInfoOrder', 'setInfoRecords']),
			...mapMutations('mdApprove', ['setInfoApprove', 'setLicenseData']),
			changesw(e) {
				console.log(e)
				this.tabCurrent = e.detail.current
			},
			// 选中某个复选框时，由checkbox时触发
			checkboxGroupChange(e) {
				console.log(e, typeof e );
				if( typeof e == 'number'){
					ins = e
				} else{
					this.plateNumberList[ins] = e
				}
				
			},
			setTime(e) {
				console.log(e)
				this.time = e.result
			},
			//转发
			forward() {
				this.personShow = true
			},
			// 工单转发成功
			appointTaskSuccess() {
				uni.$emit('updatelist', 10)
				this.$refs.uToast.show({
					title: '转发成功',
					type: 'success',
					url: '/pages/index/approval/index'
				}, 500)
			},
			appointTaskCancel() {
				this.personShow = false
			},
			//展示更多车辆
			loadMore() {
				this.showMoreBaseData = true
				this.baseDataBoxStyle.height = "unset";
				// this.showMoreBaseData = !this.showMoreBaseData;
				// if (this.showMoreBaseData) {
				// 	this.baseDataBoxStyle.height = "unset";
				// } else {
				// 	this.baseDataBoxStyle.height = "190rpx";
				// }
			},
			//取消认领
			canceltake() {
				uni.showModal({
					title: '提示',
					content: '是否确定取消认领？',
					confirmText: '确定',
					cancelText: '取消',
					success: res => {
						if (res.confirm) {
							cancelTask({
								id: this.id
							}).then(res => {
								this.orderType = 0
							}).catch(res => {
								uni.$emit('updatelist', 10)
								this.$refs.uToast.show({
									title: res.data.msg,
									type: 'warning',
									url: '/pages/index/approval/index'
								}, 300)
							})
						}
					}
				})
			},
			tabChange(index) {
				this.tabCurrent = index
			},
			//更新场地相关数据
			updatechangdimsg() {
				let params = {
					ordersId: this.detailmsg.ordersId,
					transitEndTime:this.time ,
					banTime: this.banTime
				}
				updatechandi(params).then(res => {
					console.log(res)
				}).catch(e => {
					// console.log(e.response.data.msg)
				})
			},
			//更新车牌
			updatechepaimsg() {
				let params = []
				console.log(this.plateNumberList)
				 this.detailmsg.transitCompanyInfo.forEach((d,i)=>{
					 params.push({
						 ordersId: this.detailmsg.ordersId,
						 companyId: d.id,
						 plateNumber: this.plateNumberList[i].join(',')
					 })
				 })	 
				 console.log('更新车牌数据',params)
				 return new Promise((resolve,reject)=>{
					 updateCheckCarInfo(params).then(res=>{
					 	this.requestGetLicense()
					 	console.log(res)
						resolve(res)
					 })
				 })
				
			},
			//通过审核
			approved() {
				if(!this.isUploadRoute){
					this.$toast('请重新选择路线')
					return ;
				}
				if (this.buttontype == 3 && this.stepsnumber == 3) {
					if (!this.time) {
						this.$toast('请选择运输结束时间')
						return;
					}
				}
				if (this.buttontype == 3 && this.stepsnumber == 4) {
					if (!this.detailmsg.transitRoute && !this.detailmsg.transitRouteText) {
						this.$toast('请选择导航路线')
						
					}
					// 未生成通行证则进入生成通行证页面
					else if (!this.detailmsg.transportTaskApplication) {
						this.detailmsg.banTime = this.banTime
						this.detailmsg.remarksMes = this.remarksMes
						this.setInfoApprove(this.detailmsg)
						this.$toast('请先生成通行证')
						return;
					}
					
				};
				this.showPass = true
			},
			onSure() {
				console.log(this.buttontype)
				switch (this.buttontype) {
					case '1':
						this.passin()
						break;
					case '3':
						this.comfirm_part()
						break;
					case '11':
						this.comfirm_part()
						break;
					default:
				}
			},
			//通过审核跳转
			passin() {
				uni.showModal({
					title: '提示',
					content: '是否确定提交审核？',
					confirmText: '确定',
					cancelText: '取消',
					success: res => {
						if (res.confirm) {
							postCheck({
								id: this.id,
								other: {
									result: "工单核验",
									content: this.pass_value
								}
							}).then(res => {
								this.show = false
								this.showPass = false
								uni.$emit('updatelist', 10)
								this.$refs.uToast.show({
									title: '提交成功',
									type: 'success'
								}, 500)
								uni.navigateTo({
									url: '/pages/index/approval/index'
								})
							}).catch(res => {
								uni.$emit('updatelist', 10)
								this.$refs.uToast.show({
									title: res.data.msg,
									type: 'warning',
									url: '/pages/index/approval/index'
								}, 300)
							})
						}
					}
				});
			},
			//工单流记录
			getcircul() {
				getWorkOrderLogs({
					id: this.orderId
				}).then(res => {
					console.log('************************', res)
					this.circulList = res
					this.setInfoRecords(this.circulList)
				})
			},
			// 跳转至表单盖章页面pages/webview/finnish
			orderFinishHandle() {
				this.setInfoApprove(this.detailmsg)
				this.setInfoOrder(this.detailList)
				this.setInfoRecords(this.circulList)
				uni.navigateTo({
					url: `/pages/webview/finnish?type=1`
				})
			},
			//获取分配部门
			getorgByNodeId() {
				orgByNodeId({
					nodeId: this.nodeId,
				}).then((res) => {
					res.forEach((d) => {
						this.list.push({
							nodeId: d.nodeId,
							orgId: d.orgId,
							orgName: d.orgName,
							checked: false,
							disabled: false,
						});
					});
					this.list.forEach((item, index) => {
						// 去除括号及内容
						item.orgName = item.orgName.replace(/\（.*?\）/g, '')
					})
					// 默认选中字段
					this.list.forEach((item, index) => {
						if (this.detailmsg.competentDepartment == item.orgName) {
							item.checked = true
						} else if (this.detailmsg.street == item.orgName) {
							item.checked = true
						}
					})
					this.list.forEach((item, index) => {
						if (item.checked == true) {
							this.activelist.push(item.orgId)
						}
					})
					console.log(res, 9999999, this.nodeId);
				});
			},
			// 获取审核详情
			getolddetail() {
				return new Promise((resolve, reject) => {
					getByOrdersId({
						ordersId: this.orderId
					}).then(res => {
						console.log('桃仁场地出土详情接口', res)
						this.detailmsg = res
						this.transitCompanyInfo = res.transitCompanyInfo
						// this.transitCompanyInfo.forEach((d,i)=>{
						// 	d.cardList.forEach(c=>{
						// 		this.plateNumberList[i].push(c.plateNumber)
						// 	})	
						// })
						this.transitCompanyInfo.forEach((d,i) => {
							d.carList.forEach(c => {
								this.plateNumberList[i].push(c.plateNumber)
								this.$set(c, 'checked', true)
								this.$set(c, 'disabled', false)
							})
						})
						this.setInfoApprove(this.detailmsg)
						this.time = this.detailmsg.transitEndTime || ''
						// this.banTime = this.detailmsg.banTime
						this.minDate = this.detailmsg.transitStartTime
						this.setInfoApprove(res)
						resolve(res)
					}).catch(err => {
						reject(err)
					})
				})
			},
			getdetail() {
				return new Promise((resolve, reject) => {
					getOrderDetail({
							id: this.id,
						})
						.then((res) => {
							console.log('猫总接口', res);
							this.detailList = res;
							this.setInfoOrder(this.detailList)
							if (this.detailList.type == 10) {
								this.orderType = 2;
							} else if (this.detailList.type == 11) {
								this.orderType = 3;
							} else {
								this.orderType = this.detailList.orderType;
							}
							this.buttontype = this.detailList.type;
							if (this.buttontype == 10) {}
							resolve(res);
						})
						.catch((err) => {
							reject(err);
						});
				});
			},
			//确认审核
			comfirm() {
				if (this.outorder != 0) {
					uni.showModal({
						title: "提示",
						content: "是否确定提交审核？",
						confirmText: "确定",
						cancelText: "取消",
						success: (res) => {
							if (res.confirm) {
								if (this.outorder == 1) {
									postCloseOrder({
										id: this.id,
										other: {
											result: "关闭",
											content: this.type_value
										}
									}).then(d => {
										uni.$emit('updatelist', 10)
										this.$refs.uToast.show({
											title: '关闭成功',
											type: 'success',
											url: '/pages/index/approval/index'
										}, 500)
									}).catch(res => {
										uni.$emit('updatelist', 10)
										this.$refs.uToast.show({
											title: res.data.msg,
											type: 'warning',
											url: '/pages/index/approval/index'
										}, 300)
									})
								} else if (this.outorder == 2) {
									postWithdraw({
									// allocatepostWithdraw({
										id: this.id,
										ordersId:this.detailList.id,
										other: {
											result: "退单整改",
											content: this.type_value
										}
									}).then(res => {
										uni.$emit('updatelist', 10)
										this.$refs.uToast.show({
											title: '退单成功',
											type: 'success',
											url: '/pages/index/approval/index'
										}, 500)
										// uni.navigateBack()
									}).catch(res => {
										uni.$emit('updatelist', 10)
										console.log(res)
										this.$refs.uToast.show({
											title: res.data.msg,
											type: 'warning',
											url: '/pages/index/approval/index'
										}, 300)
									})
								} else {
									postBackStep({
										id: this.id,
										other: {
											result: "返回上一节点",
											content: this.type_value
										}
									}).then(res => {
										uni.$emit('updatelist', 10)
										this.$refs.uToast.show({
											title: '返回上一节点成功',
											type: 'success',
											url: '/pages/index/approval/index'
										}, 500)
									}).catch(res => {
										uni.$emit('updatelist', 10)
										this.$refs.uToast.show({
											title: res.data.msg,
											type: 'warning',
											url: '/pages/index/approval/index'
										}, 300)
									})
								}
							}
						},
					});
				} else {
					if (this.buttontype == 2) {
						uni.showModal({
							title: "提示",
							content: "是否确定提交通过？",
							confirmText: "确定",
							cancelText: "取消",
							success: (res) => {
								if (res.confirm) {
									postOrderHandle({
										id: this.id,
										other: {
											result: "工单处置",
											content: this.type_value,
										},
									}).then((res) => {
										this.getdetail();
										this.show = false;
										uni.$emit("updatelist", 10);
										this.$refs.uToast.show({
											title: "通过成功",
											type: "success",
										}, 300);
										uni.navigateBack();
									}).catch(res => {
										uni.$emit('updatelist', 10)
										this.$refs.uToast.show({
											title: res.data.msg,
											type: 'warning',
											url: '/pages/index/approval/index'
										}, 300)
									})
								}
							},
						});
					} else if (this.buttontype == 3) {
						uni.showModal({
							title: "提示",
							content: "是否确定提交审核dd？",
							confirmText: "确定",
							cancelText: "取消",
							success: (res) => {
								if (res.confirm) {
									postOrderAudit({
										id: this.id,
										other: {
											result: "工单审核1",
											content: this.pass_value,
											name:this.detailmsg.name
										},
									}).then((res) => {
										this.getdetail();
										this.show = false;
										this.showPass = false
										this.$refs.uToast.show({
												title: "审核成功",
												type: "success",
											},
											300
										);
										setTimeout(() => {
											uni.$emit("updatelist", 10);
											uni.navigateBack();
										}, 300);
										console.log(res);
									}).catch(res => {
										uni.$emit('updatelist', 10)
										this.$refs.uToast.show({
											title: res.data.msg,
											type: 'warning',
											url: '/pages/index/approval/index'
										}, 300)
									})
								}
							},
						});
					}
				}
			},
			//任务认领
			takeClaim() {
				uni.showModal({
					title: '提示',
					content: '是否确定认领？',
					confirmText: '确定',
					cancelText: '取消',
					success: async (res) => {
						if (res.confirm) {
							// uni.showLoading({
							// 	title: '认领中',
							// })
							await getTakeTask({
								id: this.id
							}).then(res => {
								console.log('认领结果: ', res)
								this.orderType = 1
								this.$toast('认领成功', 'success')
							}).catch(res => {
								uni.$emit('updatelist', 10)
								this.$refs.uToast.show({
									title: res.data.msg,
									type: 'warning',
									url: '/pages/index/approval/index'
								}, 300)
							})
						}
					}
				})

			},
			checkboxChange(e) {
				console.log(e);
				let index = this.activelist.indexOf(e.name)
				if (index > -1) {
					this.activelist.splice(index, 1)
				} else {
					this.activelist.push(e.name)
				}
			},
			//不通过
			passout(index) {
				this.show = true;
				this.outorder = index;
			},
			// 通过
			comfirm_part() {
				// if (this.buttontype == 3 && this.stepsnumber == 3) {
				// 	if (!this.time) {
				// 		this.$toast('请选择运输结束时间')
				// 		return;
				// 	}
				// }
				// if (this.buttontype == 3 && this.stepsnumber == 4) {
				// 	if (!this.detailmsg.transitRouteText || !this
				// 		.detailmsg.transitRoute) {
				// 		this.$toast('请选择导航路线')
				// 		return;
				// 	}
				// 	// 未生成通行证则进入生成通行证页面
				// 	else if (!this.detailmsg.transportTaskApplication) {
				// 		this.setInfoApprove(this.detailmsg)
				// 		this.setLicenseData(this.licenseData)
				// 		uni.navigateTo({
				// 			url: `/pages/webview/createPdf?type=operate`
				// 		})
				// 		return;
				// 	}
				// };
				uni.showModal({
					title: "提示",
					content: "是否确定提交？",
					confirmText: "确定",
					cancelText: "取消",
					success: async (res) => {
						console.log('按钮类型buttontype: ', this.buttontype)
						if (res.confirm) {
							if (this.buttontype == 11) {
								allocatedo({
										id: this.id,
										formValue: [{
											name: "orderName",
											type: "text",
											params: {},
											display_name: "分派处置内容",
											orderName: this.type_value,
										}, ],
										other: {
											result: "部门审核通过",
											content: this.pass_value
										}
									})
									.then((d) => {
										this.show = false;
										this.showPass = false
										this.$refs.uToast.show({
											title: "处置成功",
											type: "success",
										});
										setTimeout(() => {
											uni.$emit("updatelist", 10);
											uni.navigateBack();
										}, 300);
									})
									.catch(res => {
										uni.$emit('updatelist', 10)
										this.$refs.uToast.show({
											title: res.data.msg,
											type: 'warning',
											url: '/pages/index/approval/index'
										}, 300)
									})
							} else if (this.buttontype == 10) {
								//自动分配部门
								allocate({
									id: this.id,
									orgIds: this.activelist,
									other: {
										result: "工单分配",
										content: "工单分配"
									}
								}).then(res => {
									console.log('分配成功' + res)
									this.buttontype = 11
								}).catch(res => {
									uni.$emit('updatelist', 10)
									this.$refs.uToast.show({
										title: res.data.msg,
										type: 'warning',
										url: '/pages/index/approval/index'
									}, 300)
								})
							} else {
								this.updatechangdimsg() //更新数据
								if(this.stepsnumber==3)this.updatechepaimsg()
								this.confirmPassed()
							}
						}
					},
				});
			},
			// 通过
			 confirmPassed() {
				
				 postOrderAudit({
				 	id: this.id,
				 	other: {
				 		result: "工单审核",
				 		content: this.pass_value,
				 	},
				 }).then((res) => {
				 	this.show = false;
				 	this.showPass = false
				 	
				 	this.$refs.uToast.show({
				 		title: "审核成功",
				 		type: "success",
				 	});
				 	setTimeout(() => {
				 		uni.$emit("updatelist", 10);
				 		uni.navigateBack();
				 	}, 300);
				 
				 
				 })
			},
			// 生成路线
			createRoute() {
				if (this.detailmsg.siteAddressLon && this.detailmsg.absorbAddressLon) {
					this.setInfoApprove(this.detailmsg)
					const start = `${this.detailmsg.siteAddressLon},${this.detailmsg.siteAddressLat}`
					const end = `${this.detailmsg.absorbAddressLon},${this.detailmsg.absorbAddresslat}`
					// stepsnumber大于2的时候为可编辑模式
					const type = this.detailList.isClosed != '0' ? 'readonly' : this.stepsnumber > 3 ? 'edit' : 'check'
					uni.navigateTo({
						url: `/pages/webview/navigationRoute?start=${start}&end=${end}&type=${type}&isClosed=${this.detailList.isClosed}`
					})
				} else {
					this.$toast('缺失起始点坐标')
				}
			},
			// 生成通行证pdf
			createTongxingzhengPdf() {
				if(this.detailmsg.transitRoute && this.detailmsg.transitRouteText){
					this.detailmsg.banTime = this.banTime
					this.detailmsg.remarksMes = this.remarksMes
					console.log(this.detailmsg.banTime, 'this.detailmsg.banTimethis.detailmsg.banTime', this.detailmsg)
					this.setInfoApprove(this.detailmsg)
					this.setLicenseData(this.licenseData)
					this.updatechepaimsg().then(res=>{
						
						if(this.licenseData.length){
							uni.navigateTo({
								url: `/pages/webview/createPdf?type=operate`
							})
							
						}else{
							this.$toast('暂无通行证数据')
						}
						return;
					})
					// if(this.licenseData.length){
						
					// 	uni.navigateTo({
					// 		url: `/pages/webview/createPdf`
					// 	})
					// }else{
					// 	this.$toast('暂无通行证数据')
					// }
				}else{
					this.$toast('请先选择导航路线')
				}
				console.log(9999999999)
				// if (this.detailList.isClosed != '0') return;
				// this.updatechepaimsg().then(res=>{
					
				// })
				
				
			},
			// 获取通行证数据
			requestGetLicense() {
				return getLicenseXukeZhengData({
					orderId: this.orderId
				}).then(res => {
					console.log('通行证数据: ', res)

					this.licenseData = res
					this.setLicenseData(this.licenseData)
				}).catch(err => {
					// this.$toast('通行证获取失败')
					console.log('通行证获取失败: ', err,this.licenseData,this.licenseData.length)
				})
			},

		},
	};
</script>

<style lang="scss" scoped>
	.table-cell {
		padding: 10rpx 0;
	}

	.detail-ap {
		height: 100vh;
		width: 750rpx;
		display: flex;
		flex-direction: column;
		overflow: hidden;

		.main-container {
			flex: 1;
			width: 750rpx;
			background-color: #f2f3f5;
			display: flex;
			flex-direction: column;
			overflow: hidden;

			swiper,
			swiper-item {
				height: 100% !important;
			}

			swiper-item {
				overflow-x: hidden;
				overflow-y: scroll;
			}

			.main-panel-wrap {
				display: flex;
				flex-direction: column;
			}

			.mian-title {
				padding: 32rpx;
				width: 718rpx;
				background-color: #ffffff;

				.xq_title {
					font-weight: 600;
					font-size: 40rpx;
					color: #363a44;
					margin-bottom: 24rpx;
				}

				.xq_type {
					font-size: 28rpx;
					color: #b5b7ba;
				}
			}

			.mian-content {
				flex: 1;
				height: 1rpx;
				overflow: hidden;
				overflow-y: auto;
			}

			.scroll-class {}

			.forms-container {
				padding-bottom: 100rpx;
				width: 750rpx;
				background-color: #ffffff;
				border-radius: 10rpx;

				.car-wraper {
					width: 100%;
				}

				.Category_title {
					display: flex;
					font-weight: 600;
					font-size: 32rpx;
					color: #428ffc;
					height: 92rpx;
					background-color: #f6f7f8;
					line-height: 100rpx;
					padding-left: 32rpx;

					.line {
						height: 32rpx;
						margin: 32rpx 16rpx 0 0;
						width: 4rpx;
						background-color: #428ffc;
					}
				}

				.items {
					display: flex;
					align-items: center;
					padding: 26rpx 0 26rpx 0;
					font-size: 28rpx;
					margin-left: 32rpx;
					margin-right: 32rpx;
					border-bottom: 2rpx solid #E8E9EC;

					.image-wrape {
						display: flex;
						width: 100% !important;

						.image-panel {
							display: flex;
							flex-wrap: wrap;
							width: 100% !important;
						}
					}

					.field {
						width: 242rpx;
						color: #B3B5B9;
						margin-right: 8rpx;

						.showpdf {
							margin-top: 16rpx;
							height: 200rpx;
							width: 200rpx;
							border: 1rpx solid #E8E9EC;
							border-radius: 10rpx;
							display: flex;
							justify-content: center;
							align-items: center;
							position: relative;

							.pho {
								height: 200rpx;
								width: 200rpx;
							}

							.pdf {

								height: 128rpx;
								width: 104rpx;
							}

							.delete-icon {
								width: 30rpx;
								height: 30rpx;
								position: absolute;
								top: 0;
								right: 0;
								background: url(/static/delete-icon.png) no-repeat;
								background-size: 100% 100%;
							}
						}
					}

					.edit-field {
						color: rgb(54, 58, 68) !important;
					}

					.content {
						width: 440rpx;
						color: #B3B5B9;

						.u-input {
							input {
								height: 20rpx !important;
								min-height: unset !important;
							}
						}

						// color: #363A44;
					}
				}

				.items2 {}

				.item-penel {
					padding-bottom: 50rpx;
					position: relative;
				}

				.load-more {
					position: absolute;
					left: 50%;
					transform: translateX(-50%);
					bottom: 0rpx;
					text-align: center;
					// border-bottom: 1px solid rgba(232, 233, 236, 1);
					height: 60rpx;
					line-height: 60rpx;
					color: rgba(144, 155, 165, 100);
					font-size: 28rpx;
					text-align: left;
					font-family: PingFangSC-Regular;
				}

				.line {
					height: 5rpx;
					background-color: #f2f3f5;
				}

				.title-wraper {
					display: flex;
					border-bottom: 1px solid rgba(232, 233, 236, 1);
					height: 112rpx;
					line-height: 112rpx;

					.title {
						min-width: 200rpx;
						color: rgba(179, 181, 185, 100);
						font-size: 28rpx;
						text-align: left;
						font-family: PingFangSC-Medium;
					}

					.name {
						color: rgba(179, 181, 185, 100);
						font-size: 28rpx;
						text-align: left;
						font-family: PingFangSC-Medium;
					}
				}

				.content-item-wrapper {
					display: flex;
					border-bottom: 1px solid rgba(232, 233, 236, 1);
					min-height: 112rpx;
					line-height: 112rpx;
					width: 700rpx;
					flex-wrap: nowrap;

					.title {
						min-width: 200rpx;
						color: rgba(179, 181, 185, 100);
						font-size: 28rpx;
						text-align: left;
						font-family: PingFangSC-Medium;
					}

					.name {
						color: rgba(179, 181, 185, 100);
						font-size: 28rpx;
						text-align: left;
						font-family: PingFangSC-Medium;
					}
				}
			}

			.circul {
				display: flex;
				margin-left: 22rpx;
				margin-bottom: 40rpx;
				width: 750rpx;

				.type {
					margin-top: 22rpx;
					height: 50rpx;
					width: 50rpx;
					background-color: #2979ff;
					color: #ffffff;
					font-size: 31rpx;
					border-radius: 50%;
					text-align: center;
					line-height: 50rpx;
				}

				.circul_content {
					padding: 22rpx;
					margin-left: 22rpx;
					background-color: #ffffff;
					width: 588rpx;
					border-radius: 10rpx;

					.circul_field {
						margin-top: 22rpx;
					}
				}
			}
		}

		.footer {
			display: flex;
			justify-content: center;

			width: 750rpx;
			height: 128rpx;
			background-color: #ffffff;
			font-size: 29rpx;
			box-shadow: 2rpx 0 6rpx rgba(0, 0, 0, 0.12), 0 0 6rpx rgba(0, 0, 0, 0.04);

			.chuzhi {
				height: 87rpx;
				width: 170rpx;
				border: 1rpx solid #428FFC;
				border-radius: 20rpx;
				font-size: 25rpx;
				color: #FFFFFF;
				background-color: #428FFC;
				margin-top: 14rpx;
				// margin-right: 5rpx;
				margin-left: 12rpx;
			}

			.cancel {
				height: 87rpx;
				width: 339rpx;
				border: 1rpx solid #428ffc;
				border-radius: 50rpx;
				color: #428ffc;
				margin-top: 14rpx;
				// margin-left: 32rpx;
			}

			.confim {
				height: 87rpx;
				width: 339rpx;
				border: 1rpx solid #428ffc;
				border-radius: 50rpx;
				background-color: #428ffc;
				color: #ffffff;
				margin-top: 14rpx;
				margin-left: 16rpx;
			}

			.take-task {
				height: 87rpx;
				width: 692rpx;
				line-height: 87rpx;
				border: 1rpx solid #428ffc;
				border-radius: 50rpx;
				background-color: #428ffc;
				color: #ffffff;
				margin-top: 14rpx;
			}
		}
	}

	.pop {
		height: 950rpx;
		border-radius: 20rpx;

		.pop_title {
			color: #363a44;
			font-size: 32rpx;
			padding: 40rpx 0 32rpx 32rpx;
			border-bottom: 1rpx solid #efefef;
		}

		.title {
			padding: 20rpx;
			display: flex;
			justify-content: space-between;
		}

		.checkbox-group {
			padding: 20rpx;
		}
	}

	img {
		height: 116rpx;
		width: 116rpx;
		margin-right: 20rpx;
	}

	.u-tr {
		height: 112rpx;
	}

	#navi_map {
		height: 650rpx;
	}

	.map_box {
		height: 650rpx;

	}

	.tabList {
		height: 80rpx;
		width: 750rpx;
		z-index: 99;
		background-color: #FFFFFF;
		border-bottom: .5rpx solid #DBDBDB;
	}
</style>